﻿
Imports LibMultiPlug.Core.Reporting

Namespace Forms

    Public Class ReportForm
        Inherits WeifenLuo.WinFormsUI.Docking.DockContent
        Implements LibMultiPlug.Core.Plugins.Interfaces.IFormOptions


        Private _report As Report
        Private _reportService As LibMultiPlug.Core.Services.ServiceDefinitions.ReportService

        Public Sub New()

            ' Dieser Aufruf ist für den Designer erforderlich.
            InitializeComponent()

            ' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu.

            _reportService = LibMultiPlug.Core.Services.ServiceManager.GetInstance().GetReportingService()

        End Sub

        Public Overloads Sub Show(ByVal dockPanel As WeifenLuo.WinFormsUI.Docking.DockPanel, ByVal repoId As Integer)

            _report = _reportService.GetReport(repoId)

            Call InternalInitialize()

            MyBase.Show(dockPanel)

        End Sub

        Private Sub InternalInitialize()

            Me.Text = _report.Name
            lblHeader.Text = _report.Name

            Me.dgvReport.DataSource = _report.GetData()

            Me.dgvReport.Columns(_report.IdColumn).Visible = False

            dgvReport.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells

        End Sub

        Private Sub DataGridView1_CellContentDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) _
            Handles dgvReport.CellDoubleClick
            Dim id As Integer = CInt(dgvReport.Rows(e.RowIndex).Cells(_report.IdColumn).Value)
            Dim detailForm As IReportable = CType(System.Activator.CreateInstance(_report.GetStartType()), IReportable)
            detailForm.Show(Me.DockPanel, id)

        End Sub



        Public Sub Delete() Implements LibMultiPlug.Core.Plugins.Interfaces.IFormOptions.Delete

        End Sub

        Public Sub [New]() Implements LibMultiPlug.Core.Plugins.Interfaces.IFormOptions.New

        End Sub

        Public Sub Open() Implements LibMultiPlug.Core.Plugins.Interfaces.IFormOptions.Open

        End Sub

        Public Event OptionsChanged(ByVal sender As Object, ByVal e As System.EventArgs) Implements LibMultiPlug.Core.Plugins.Interfaces.IFormOptions.OptionsChanged

        Public Sub PagePreview() Implements LibMultiPlug.Core.Plugins.Interfaces.IFormOptions.PagePreview

        End Sub

        Public Sub Print() Implements LibMultiPlug.Core.Plugins.Interfaces.IFormOptions.Print

        End Sub

        Public Sub Refresh1() Implements LibMultiPlug.Core.Plugins.Interfaces.IFormOptions.Refresh
            Call InternalInitialize()
        End Sub

        Public Sub Save() Implements LibMultiPlug.Core.Plugins.Interfaces.IFormOptions.Save

        End Sub

        Public Sub SaveAs() Implements LibMultiPlug.Core.Plugins.Interfaces.IFormOptions.SaveAs

        End Sub

        Public ReadOnly Property SetCoopDesign As Boolean Implements LibMultiPlug.Core.Plugins.Interfaces.IFormOptions.SetCoopDesign
            Get

            End Get
        End Property

        Public ReadOnly Property SetDelete As Boolean Implements LibMultiPlug.Core.Plugins.Interfaces.IFormOptions.SetDelete
            Get

            End Get
        End Property

        Public ReadOnly Property SetNew As Boolean Implements LibMultiPlug.Core.Plugins.Interfaces.IFormOptions.SetNew
            Get

            End Get
        End Property

        Public ReadOnly Property SetOpen As Boolean Implements LibMultiPlug.Core.Plugins.Interfaces.IFormOptions.SetOpen
            Get

            End Get
        End Property

        Public ReadOnly Property SetPagePreview As Boolean Implements LibMultiPlug.Core.Plugins.Interfaces.IFormOptions.SetPagePreview
            Get

            End Get
        End Property

        Public ReadOnly Property SetPrint As Boolean Implements LibMultiPlug.Core.Plugins.Interfaces.IFormOptions.SetPrint
            Get

            End Get
        End Property

        Public ReadOnly Property SetRefresh As Boolean Implements LibMultiPlug.Core.Plugins.Interfaces.IFormOptions.SetRefresh
            Get
                Return True
            End Get
        End Property

        Public ReadOnly Property SetSave As Boolean Implements LibMultiPlug.Core.Plugins.Interfaces.IFormOptions.SetSave
            Get

            End Get
        End Property

        Public ReadOnly Property SetSaveAs As Boolean Implements LibMultiPlug.Core.Plugins.Interfaces.IFormOptions.SetSaveAs
            Get

            End Get
        End Property
    End Class

End Namespace
